home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / dejagnu.lha / dejagnu-1.0.1 / expect / exp_test.c < prev    next >
C/C++ Source or Header  |  1993-04-07  |  687b  |  34 lines

  1. /*
  2.  * exp-test -- this is a simple C program to test the interactive functions of expect.
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7.  
  8. #define ARRAYSIZE 128
  9.  
  10. main (argc, argv)
  11. int argc;
  12. char *argv[];
  13. {
  14.   char line[ARRAYSIZE];
  15.  
  16.   do {
  17.     memset (line, NULL,ARRAYSIZE);
  18.     fgets (line, ARRAYSIZE, stdin);
  19.     *(line + strlen(line)-1) = NULL; /* get rid of the newline */
  20.  
  21.     /* look for a few simple commands */
  22.     if (strncmp (line,"prompt ", 6) == 0) {
  23.       printf ("%s (y or n) ?", line + 6);
  24.       if (getchar() == 'y')
  25.     puts ("YES");
  26.       else
  27.     puts ("NO");
  28.     }
  29.     if (strncmp (line, "print ", 6) == 0) {
  30.       puts (line + 6);
  31.     }
  32.   } while (strncmp (line, "quit", 4));
  33. }
  34.